Dynamically typed languages such as PHP and Ruby have been widely used these days in web servers and the like. A script written in such a language is often executed by using the interpreter technology. However, some applications require the script to be executed after the conversion into bytecode which runs directly on JAVA Virtual Machine (JAVA VM), for example, in order to achieve a fast execution. In this case, it is difficult to efficiently execute a caller for each method/function while converting source code written in a dynamically typed language into target code written in a statically typed language such as JAVA. In practice, the above script file needs to be compiled during the execution of the source code, and thus a specific concern is in how to efficiently compile the script file. This concern arises mainly for the following two reasons. Firstly, there is no independently defined function in a statically typed language such as JAVA. For this reason, a JAVA class needs to be prepared for each function/method of a dynamically typed language. Secondly, when a caller function/method in a program in a dynamically typed language is converted, the type of its callee cannot be specified in general. The conversion can be made easily by using a reflection mechanism such as JAVA Reflection API. However, the reflection mechanism causes large overhead due to its reflective behavior during runtime.
There is a method for the conversion without using the reflection mechanism, in which a class for implementation is prepared for every entity of functions/methods of a dynamically typed language, and the classes thus prepared can be called as a subclass of a specific class serving as a fixed interface. However, with the method, a lot of classes for respective functions/methods must be prepared for implementations of callee functions/methods. Accordingly, an extra memory is calculated for storing metadata required to describe the above classes themselves. This results in an inconvenience that a large portion of a memory area in an execution system such as JAVA VM is consumed.
Against this background, there is a requirement of a method capable of reducing memory consumption when converting source code written in a dynamically typed language into target code written in a statically typed language to execute the target code.